-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add AnonConst as potential parent_item #71477
Conversation
| | ||
help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | ||
| | ||
LL | let f = [0; (-4_isize).try_into().unwrap()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This help message was incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice if we changed |
Can implement it in a separate PR 👍 |
I don't think this is the right approach, |
This PR is needed for https://github.com/rust-lang/rust/blob/4b575996168edbc5b7ad46229f5ed3bfee35484c/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs #70 (#71154 uses it to get the correct typeck_tables)
rust/src/librustc_middle/hir/map/mod.rs Line 564 in bf45975
which currently results in wrong diagnostics in rust/src/librustc_typeck/check/demand.rs Lines 597 to 601 in 413a129
What do you want to use instead? |
You want to loop through the parents with If you want to be more efficient you could probably add an cc @ecstatic-morse @oli-obk @wesleywiser on |
I now use the following in #71154: pub fn enclosing_body_owner(&self, hir_id: HirId) -> HirId {
for (parent, _) in self.parent_iter(hir_id) {
if let Some(body) = self.maybe_body_owned_by(parent) {
return self.body_owner(body);
}
}
bug!("no `enclosing_body_owner` for hir_id `{}`", hir_id);
} This means that this PR now only fixes incorrect suggestions afaict. Don't fully understand when |
Closing this for now as this is not the correct approach. Will try and make a more general fix for |
Fix `is_const_context`, update `check_for_cast` A better version of rust-lang#71477 Adds `fn enclosing_body_owner` and uses it in `is_const_context`. `is_const_context` now uses the same mechanism as `mir_const_qualif` as it was previously incorrect. Renames `is_const_context` to `is_inside_const_context`. I also updated `check_for_cast` in the second commit, so r? @estebank (I removed one lvl of indentation, so it might be easier to review by hiding whitespace changes)
Fix `is_const_context`, update `check_for_cast` A better version of rust-lang#71477 Adds `fn enclosing_body_owner` and uses it in `is_const_context`. `is_const_context` now uses the same mechanism as `mir_const_qualif` as it was previously incorrect. Renames `is_const_context` to `is_inside_const_context`. I also updated `check_for_cast` in the second commit, so r? @estebank (I removed one lvl of indentation, so it might be easier to review by hiding whitespace changes)
This prevents some help messages in const contexts, due to
rust/src/librustc_typeck/check/demand.rs
Lines 597 to 601 in 413a129
considering that the check in
is_const_context
was previously unreachable,this is actually a bugfix 😆
rust/src/librustc_middle/hir/map/mod.rs
Line 563 in 413a129
r? @eddyb cc @estebank